<template>
  <div class="app-container">
    <!-- :stretch="true"  选项卡平铺 -->
    <el-tabs v-model="outpFeesActive" style="height: 100%;" @tab-click="tabClick">
      <el-tab-pane label="门诊收费" name="0" style="height: 100%;overflow-y: auto;">
        <outpatient-fee-index ref="outpatientFeeIndexRef" :electronic-invoice-is-start-using="electronicInvoiceIsStartUsing"
                              :detailAudit-is-start-using="detailAuditIsStartUsing"/>
      </el-tab-pane>
      <el-tab-pane label="门诊收费记录" name="1" style="height: 100%;overflow-y: auto;">
        <outpatient-fee-records ref="outpatientFeeRecordsRef"/>
      </el-tab-pane>
      <el-tab-pane label="门诊退费" name="2">
        <outpatient-refund ref="outpatientRefundRef"  :electronic-invoice-is-start-using="electronicInvoiceIsStartUsing"/>
      </el-tab-pane>
      <el-tab-pane label="门诊结账" name="3">
        <outp-acct-master ref="outpAcctMasterRef"/>
      </el-tab-pane>
      <el-tab-pane label="门诊结账记录查询" name="4">
        <outp-acct-master-record ref="outpAcctMasterRecordRef" :acct-type="'2'"/>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>


<script lang="ts">
export default {
  name: "OutpFeesIndex"
}
</script>
<script setup lang="ts">
import outpatientFeeRecords from './outpatientFeeRecords.vue';
import outpatientRefund from './outpatientRefund.vue';
import outpatientFeeIndex from '@/views/finance/outpFees/index.vue';
import outpAcctMaster from '../../outpAcct/master.vue'
import outpAcctMasterRecord from '../../outpAcct/masterRecord.vue'
import {selectConfigByCache} from "@/api/system/orgConfig.ts"
import {useUserStoreHook} from "@/store/modules/user.ts";

const useUserStore = useUserStoreHook();
// 登录用户信息
const userInfo = <UserInfoBusi>useUserStore.user.userInfo;
const {proxy} = getCurrentInstance() as any;
const outpFeesActive = ref('0')

const outpatientFeeIndexRef = ref()
const outpatientFeeRecordsRef = ref()
const outpatientRefundRef = ref()
const outpAcctMasterRef = ref()
const outpAcctMasterRecordRef = ref()
//是否启用电子发票流程
const electronicInvoiceIsStartUsing = ref("N")
//是否启用事前事中审核流程
const detailAuditIsStartUsing = ref("N")
/**
 * tab页点击事件
 * @param obj
 */
function tabClick(obj: any) {
  const objThis = toRaw(obj)
  if (objThis.props.name === '0') {

  } else if (objThis.props.name === '1') {
    outpatientFeeRecordsRef.value.handleQuery()
  } else if (objThis.props.name === '2') {

  } else if (objThis.props.name === '3') {
    outpAcctMasterRef.value.refreshClick()
  } else if (objThis.props.name === '4') {
    outpAcctMasterRecordRef.value.handleQuery()
  }
}

/**
 * 通过orgId key获取对应的机构参
 */
function selectConfigByCacheFun() {
  // 是否启用电子发票流程
  selectConfigByCache(userInfo.orgId, "electronicInvoice.is.start.using").then((res => {
    electronicInvoiceIsStartUsing.value = res.data.configValue
  }));
  // 是否启用事前事中审核流程
  selectConfigByCache(userInfo.orgId, "detailAudit.is.start.using").then((res => {
    detailAuditIsStartUsing.value = res.data.configValue
  }));
}

selectConfigByCacheFun()
</script>

<style scoped>
:deep(.el-tabs__item) {
  min-width: 200px;
  height: 30px;
}

:deep(.el-tabs__content) {
  height: calc(100% - 30px);
}

:deep(.el-tabs__nav-scroll) {
  background-color: #ffffff;
}

:deep(.el-tabs__header) {
  margin: 0 0 0px;
  box-shadow: 0 0 18px 0 #878787;
}
</style>
